package edu.hawaii.duedates;

import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/**
 * Test the UhLibrary class to check that it functions properly.
 * 
 * @author Erin Kim and Arthur Shum
 */
@Ignore
public class TestUhLibrary {

  /** The patron's UH ID number. */
  private String uhId;

  /** The patron's last name. */
  private String lastName;

  /** The string (actually, part of the string) expected to be returned by the getInfo method. */
  private String expected;

  /**
   * Sets the uhId, lastName, and expected fields. Sets the uhId and lastName fields according to
   * the system properties (passed from the command line). Sets the expected field to the
   * appropriate string, depending on whose library account we are checking.
   */
  @Before
  public void setExpected() {
    this.uhId = System.getProperty("uhl.uhid");
    this.lastName = System.getProperty("uhl.lastname");

    // Erin currently has Pride and Prejudice checked out.
    if ("kim".equalsIgnoreCase(this.lastName)) {
      this.expected = "Pride and prejudice";
    }
    // Arthur currently has no items checked out.
    else if ("shum".equalsIgnoreCase(this.lastName)) {
      this.expected = "No items checked out from the University of Hawaii Library System";
    }

  }

  /**
   * Tests that the the string returned by the getInfo method contains the expected return string.
   * If it does, then it is almost certain that the actual returned string is correct.
   * 
   * @throws Exception If an error occurs during the test.
   */
  @Test
  public void test() throws Exception {
    Library uhl = new UhLibrary(this.uhId, this.lastName);
    String actual = uhl.getInfo();
    Boolean equality = actual.contains(this.expected);
    assertTrue("Actual results contain expected results", equality);
  }

}
